package com.itheima.edu.info.manager.controller;

import com.itheima.edu.info.manager.domain.Teacher;
import com.itheima.edu.info.manager.service.TeacherService;

import java.util.Scanner;

public class TeacherController {
    public void start() {
        Scanner sc = new Scanner(System.in);
        lo: while(true){
            System.out.println("--------欢迎来到 <老师> 管理系统--------");
            System.out.println("请输入您的选择: 1.添加老师  2.删除老师  3.修改老师  4.查看老师  5.退出");
            String choice = sc.next();
            switch(choice){
                case"1":
                   //System.out.println("添加老师");
                    addTeacher();
                    break;
                case"2":
                   System.out.println("删除老师");
                    break;
                case"3":
                  System.out.println("修改老师");
                    break;
                case"4":
                   System.out.println("查看老师");
                    break;
                case"5":
                    System.out.println("感谢您使用老师管理系统,再见!");
                    break lo;
                default:
                    System.out.println("您输入的有误,请重新输入!");
                    break;
            }
        }
    }

    public void addTeacher() {
        //键盘接收老师对象
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入教师工号:");
        String id = sc.next();
        System.out.println("请输入教师姓名:");
        String name = sc.next();
        System.out.println("请输入教师年龄:");
        String age = sc.next();
        System.out.println("请输入教师生日:");
        String birthday = sc.next();
        //封装进教师类中
        Teacher teacher = new Teacher();
        teacher.setId(id);
        teacher.setName(name);
        teacher.setAge(age);
        teacher.setBirthday(birthday);
        //交给业务员中的添加方法,返还一个boolean类型的值
        TeacherService teacherService = new TeacherService();
        boolean flag = teacherService.addTeacher();
        //打印输入添加结果
        if(flag){
            System.out.println("添加成功!");
        }else{
            System.out.println("添加失败!");
        }
    }
}
